//
//  StepModel.m
//  uteped_sdk
//
//  Created by mateng on 2024/2/28.
//

#import "StepModel.h"

@implementation StepModel

- (void)from:(UTEModelMotionFrame*)data frameItem:(UTEModelMotionFrameItem*)frameItem {
    UTEModelMotionFrameItemContent *content = frameItem.content;
    self.time = [DateUtils timeToInt:frameItem.time fmt:FMT_TIME_SECS];
    self.startTime = data.startTime;
    self.endTime = self.time; // iOS 缺失,
    
    self.step = content.step;
    self.distance = content.distance;
    self.offset = frameItem.offset;
//    self.type = 0;//iOS 缺失
    self.calories = content.calorie;
    
    self.calendarTime = [DateUtils timeStampToString:self.time fmt:FMT_TIME_CLANDER_TIME];
    self.calendar = [DateUtils timeStampToString:self.time fmt:FMT_TIME_CLANDER];
    
    [self.storeData setObject:@(self.time) forKey:@"time"];
    [self.storeData setObject:@(self.startTime) forKey:@"start_time"];
    [self.storeData setObject:@(self.endTime) forKey:@"end_time"];
    [self.storeData setObject:@(self.step) forKey:@"step"];
    [self.storeData setObject:@(self.distance) forKey:@"distance"];
    [self.storeData setObject:@(self.offset) forKey:@"offset"];
//    [self.storeData setObject:@(self.type) forKey:@"type"];
    [self.storeData setObject:@(self.calories) forKey:@"calories"];
    [self.storeData setObject:self.calendarTime forKey:@"calendar_time"];
    [self.storeData setObject:self.calendar forKey:@"calendar"];
}

- (BOOL)validateValue {
    return !(self.step == 0 && self.distance == 0 && self.calories == 0);
}
@end
